package com.huawei.appgallery.forum.cards.widget;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.forum.base.card.bean.PostTime;
import com.huawei.appgallery.forum.base.card.bean.Section;
import huawei.widget.HwTextView;
import o.azb;
import o.bsp;
import o.bsy.b;
import o.bsy.c;
import o.bsy.e;
import o.btc;
import o.bth;
import o.eqx;

public class PostSectionContentView extends RelativeLayout {
    private bth ʻ;
    private HwTextView ˊ;
    private ImageView ˋ;
    private TextView ˎ;
    private HwTextView ˏ;
    private Context ॱ;

    public PostSectionContentView(Context context) {
        super(context);
        ˋ(context);
    }

    public PostSectionContentView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ˋ(context);
    }

    public PostSectionContentView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ˋ(context);
    }

    public void setSectionContentClickListener(bth o_bth) {
        this.ʻ = o_bth;
    }

    private void ˋ(Context context) {
        this.ॱ = context;
        View inflate = ((LayoutInflater) context.getSystemService("layout_inflater")).inflate(b.ॱ, this);
        this.ˋ = (ImageView) inflate.findViewById(c.ͺ);
        azb.ॱ(this.ˋ);
        this.ˏ = (HwTextView) inflate.findViewById(c.ʾ);
        this.ˎ = (TextView) inflate.findViewById(c.ˈ);
        this.ˊ = (HwTextView) inflate.findViewById(c.ॱᐝ);
        ॱ(this.ˋ);
        ॱ(this.ˎ);
        ˏ(inflate);
    }

    public void setData(Section section, PostTime postTime) {
        Object obj = null;
        if (section != null) {
            eqx.ˏ(this.ˋ, section.ॱ(), "app_default_icon");
            obj = section.ˏ();
        }
        if (TextUtils.isEmpty(obj)) {
            obj = "";
        }
        this.ˏ.setText(obj);
        int ˏ = bsp.ˏ(this.ˏ, obj);
        int ˏ2 = ˏ();
        TextView textView = this.ˎ;
        if (ˏ2 <= ˏ) {
            ˏ = ˏ2;
        }
        textView.setWidth(ˏ);
        if (postTime != null) {
            this.ˊ.setText(btc.ˏ(this.ॱ, postTime));
            this.ˊ.setVisibility(0);
            return;
        }
        this.ˊ.setVisibility(8);
    }

    private void ॱ(View view) {
        if (view != null) {
            view.setOnClickListener(new 5(this));
        }
    }

    private void ˏ(View view) {
        if (view != null) {
            view.setOnClickListener(new 1(this));
        }
    }

    public int ˏ() {
        return (azb.ॱ(this.ॱ) - this.ॱ.getResources().getDimensionPixelOffset(e.ˎˎ)) - (this.ॱ.getResources().getDimensionPixelOffset(e.ʿ) * 3);
    }
}
